package com.top.ruizhong.main.notice

import android.app.Activity
import android.content.Intent
import com.blankj.utilcode.util.ConvertUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.module.lemlin.base.BaseAbstractActivity
import com.module.lemlin.custom.SpacingItemDecoration
import com.top.ruizhong.R
import kotlinx.android.synthetic.main.activity_message_bulletin.*

class MessageBulletinActivity : BaseAbstractActivity() {

    companion object {
        private const val EXTRA_KEY_TITLE = "EXTRA_KEY_TITLE"
        fun open(activity: Activity, title: String) {
            val intent = Intent(activity, MessageBulletinActivity::class.java)
            intent.putExtra(EXTRA_KEY_TITLE, title)
            activity.startActivity(intent)
        }
    }

    private val messageAdapter =
        object : BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_message_bulletin) {
            override fun convert(holder: BaseViewHolder, item: String) {

            }
        }

    override val layoutResId: Int
        get() = R.layout.activity_message_bulletin

    override fun stateBar(): StatusBar {
        return StatusBar(
            isLightMode = true,
            color = R.color.colorWhite,
            view = flMessageBulletinBar
        )
    }

    override fun initView() {
        ivSMessageBulletinBack.setOnClickListener { this.finish() }

        intent?.getStringExtra(EXTRA_KEY_TITLE)?.let {
            tvMessageBulletinTitle.text = it
        }

        rvMessageBulletinBody.apply {
            val decoration = SpacingItemDecoration(
                vGap = ConvertUtils.dp2px((15f)),
                hGap = ConvertUtils.dp2px((15f))
            )
            addItemDecoration(decoration)
        }.adapter = messageAdapter
    }

    override fun initData() {
        val videos: MutableList<String> = mutableListOf()
        for (index in 0..10) {
            videos.add(index.toString())
        }
        messageAdapter.setNewInstance(videos)
    }

}